﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Mindfor.WebMP.Mvc.Models;

namespace Mindfor.Sites.Views.Shared
{
	public abstract class LinkButtonTemplate : Mindfor.WebMP.Mvc.Views.RazorViewPage<LinkButtonData>
	{
		public string GetAttributes()
		{
			string attrs = "";
			if (Model.AdditionalHtmlAttributes != null)
			{
				foreach (string key in Model.AdditionalHtmlAttributes.Keys)
				{
					if (key != "class" && !string.IsNullOrEmpty(key))
					{
						var val = (Model.AdditionalHtmlAttributes[key] as string ?? "").Trim();
						if (val.Length > 0)
							attrs += " " + key.Replace('_', '-') + "=\"" + val + "\" ";
					}
				}
			}

			return attrs;
		}

		public string GetAdditionalClasses()
		{
			string classes = "";
			if (Model.AdditionalHtmlAttributes != null)
			{
				foreach (string key in Model.AdditionalHtmlAttributes.Keys)
				{
					if (key == "class")
					{
						classes += " " + Model.AdditionalHtmlAttributes[key];
					}
				}
			}

			return classes;
		}
	}
}